diff --git a/source/blender/python/generic/bpy_threads.c b/source/blender/python/generic/bpy_threads.c
index 5507aa73183..4807c1f5071 100644
--- a/source/blender/python/generic/bpy_threads.c
+++ b/source/blender/python/generic/bpy_threads.c
@@ -29,14 +29,11 @@
 /* analogue of PyEval_SaveThread() */
 BPy_ThreadStatePtr BPY_thread_save(void)
 {
-	PyThreadState *tstate = PyThreadState_Swap(NULL);
-	/* note: tstate can be NULL when quitting Blender */
-
-	if (tstate && PyEval_ThreadsInitialized()) {
-		PyEval_ReleaseLock();
+	/* The thread-state can be NULL when quitting Blender. */
+	if (_PyThreadState_UncheckedGet()) {
+		return (BPy_ThreadStatePtr)PyEval_SaveThread();
 	}
-
-	return (BPy_ThreadStatePtr)tstate;
+	return NULL;
 }
 
 /* analogue of PyEval_RestoreThread() */
